
<template>
    <div class="contract-detial-page change-bank-card-detial contract-detail-page" :class="[isApprove ? 'approve':'no-approve',isReadOnly ? 'readOnly':'']">
        <Detail
            :Obj="Obj"
            :spinShow="spinShow"
            :isSP="isSP"
            :isApprove="isApprove"
            :isApproved="isApproved"
            :isReadOnly="isReadOnly"
            :pageParams="pageParams"
            :contractNo="contractNo"
            :dataDict="dataDict"
            :userInfo="userInfo"
            :roleType="roleType"
            :businessSource="businessSource"
            @showSpin="showSpin"
            @closeSpin="closeSpin"
            @back="back"
        />
        <Spin size="large" fix v-if="spinShow"></Spin>
    </div>
</template>
<script>
    import { mapGetters } from "vuex";

    import { channelType, businessSource } from "_p/basic/api/contract/channel-type/channel-type";
    import { getDictDataList } from "_p/basic/assets/contract/js/utils";

    import Detail from "./change-bank-card-detial";

    export default {
        name: "ChangeBankCardDetial",
        components: { Detail },
        data() {
            return {
                Obj: {},
                spinShow: false,
                isSP: null, // 是否是供应商
                isApprove: null, //是否是审批页面
                isApproved: null, //是否 审批完成
                isReadOnly: null,
                pageParams: {},
                contractNo: null, //合同号
                // 放款模式(loanModel) 变更类型  变更主体(PersonRoleType) 还款银行(repaymentBank) 持卡人(PersonRoleTypeEnum)
                dicttArr: ["loanModel", "PersonRoleType","repaymentBank","PersonRoleTypeEnum"],
                dataDict: {}
            };
        },
        computed: {
            ...mapGetters({ userInfo: "userInfo", roleType: "roles" })
        },
        created() {
            this.getParams();
        },
        mounted() {
            this.init();
            console.group('银行卡变更详情' + "页面初始数据：");
            console.log("userInfo:", this.userInfo);
            console.log("pageParams:", this.pageParams);
            console.log("roleType:", this.roleType);
            console.log("isSP:", this.isSP);
            console.log("businessSource:", this.businessSource);
            console.log("isApprove:", this.isApprove);
            console.log("isApproved:", this.isApproved);
            console.log("isReadOnly:", this.isReadOnly);
            console.log("contractNo:", this.Obj);

            console.groupEnd();
        },
        methods: {
            init() {
                this.getDictDataList();
            },
            // 获取初始数据
            getParams() {
                const pageParams = this.afs.getPageParams(this);
                const { contractNo, caseNo, processStatus,isReadOnly } = pageParams;
                this.pageParams = pageParams;
                this.contractNo = contractNo;
                this.caseNo = caseNo;
                this.businessSource = businessSource(this.roleType);
                this.Obj = {
                    caseNo,
                    contractNo,
                    processStatus,
                    roleType: this.isSP,
                    type:'bankCardChange'
                    // roleType: this.roleType
                };
                this.isApprove =
                    !!processStatus &&
                    (processStatus === "repairedUnderReview" ||
                        processStatus === "underReview"  ||
                        processStatus === "noSubmission" ||
                        processStatus === "submission");
                this.isApproved = !!processStatus && processStatus === "approved";
                this.isSP = channelType(this.$route.meta.params);
                this.isReadOnly = isReadOnly;
            },
            getDictDataList() {
                getDictDataList(this.dicttArr).then(res => {
                    console.group("数据字典:");
                    console.log(this.dicttArr.join("  "));
                    console.log(JSON.parse(JSON.stringify(res)));
                    console.groupEnd();
                    this.dataDict = res;
                });
            },
            showSpin() {
                this.spinShow = true;
            },
            closeSpin() {
                this.spinShow = false;
            },
            back() {
                //关闭页面
                this.afs.closeTab(this);
            }
        }
    };
</script>
<style lang="less" >
    @import "../../../../styles/common/form.less";
</style>
